package com.googlecode.continuity.plugin.project.client;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.googlecode.continuity.core.client.ContinuityGroup;
import com.googlecode.continuity.core.client.Group;

/**
 * Project
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class Project implements IsSerializable, Serializable {
// ------------------------------ FIELDS ------------------------------

  private ContinuityGroup members;
  private String name;
  private int id;
  /**
   * @gwt.typeArgs <com.googlecode.continuity.plugin.project.client.Milestone>
   */
  private Set milestones;
  private String description;
  private String repositoryLocation;

// --------------------- GETTER / SETTER METHODS ---------------------

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getRepositoryLocation() {
    return repositoryLocation;
  }

  public void setRepositoryLocation(String repositoryLocation) {
    this.repositoryLocation = repositoryLocation;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public void addMilestone(Milestone milestone) {
    getMilestones().add(milestone);
    milestone.addProject(this);
  }

  public void removeMileStone(Milestone milestone) {
    getMilestones().remove(milestone);
  }

  public Set getMilestones() {
    if (milestones == null) {
      milestones = new HashSet();
    }
    return milestones;
  }

  public ContinuityGroup getMembers() {
    if (members == null) {
      members = new Group();
    }
    return members;
  }

  public void setMembers(ContinuityGroup members) {
    this.members = members;
  }

  private void setMilestones(Set milestones) {
    this.milestones = milestones;
  }
}
